package cn.hy.today;

import java.util.HashSet;
import java.util.Set;

class Solution_383 {
    public boolean canConstruct(String ransomNote, String magazine) {
        int l1 = ransomNote.length();
        int l2 = magazine.length();
        if (l1 > l2) {
            return false;
        }
        int[] cnt =  new int[26];
        for(char c : magazine.toCharArray()) {
            cnt[c- 'a'] ++;
        }
        for(char c : ransomNote.toCharArray()){
            cnt[c-'a']--;
            if (cnt[c-'a'] < 0) {
                return false;
            }
        }
        return true;
    }
}